package ru.isys.view;

import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;

public class LoadWSDLView extends JFrame {

	private static final long serialVersionUID = 1L;

	File selectedFile;

	public LoadWSDLView(String title) {
		super(title);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	}

	public File getSelectedFile() {
		JFileChooser chooser = new JFileChooser();
		FileFilter filter = new FileFilter() {

			@Override
			public String getDescription() {
				return "Файлы XML (.xml)";
			}

			@Override
			public boolean accept(File file) {
				String name = file.getName().toLowerCase();
				if (name.endsWith((String) "xml") || file.isDirectory()) {
					return true;
				}
				return false;
			}
		};
		chooser.setFileFilter(filter);
		int ret = chooser.showDialog(null, "Открыть WSDL");

		if (ret == JFileChooser.APPROVE_OPTION) {
			selectedFile = chooser.getSelectedFile();
		}
		return selectedFile;
	}
}
